//
//  NativeAdCellModel.swift
//  iPhone
//
//  Created by Toj on 5/24/23.
//

import UIKit
import GoogleMobileAds

class NativeAdCellModel: NSObject {
    
    private var _cellSize = CGSize.def_cipher
    
    private(set) var isAd = false
    private(set) var name = ""
    private(set) var materials = ""
    private(set) var descrip = ""
    private(set) var spaceID = ""
    
    private(set) var admobModel: STAdmobModel?
    
    init(_ model: NativeAdModel, cellSize: CGSize) {
        super.init()
        _cellSize = cellSize
        isAd = model.is_ad == 2
        descrip = model.description
        guard isAd else {
            name = model.name
            materials = model.poster
            return
        }
        guard let adMaterial = model.adMaterial else { return }
        admobModel = adMaterial
        materials = adMaterial.materials
        name = adMaterial.name
        spaceID = adMaterial.space_id
    }
}

extension NativeAdCellModel: UICollectionViewCellModelProtocol {
    
    /// 注册类
    static var registerCell: UICollectionViewCell.Type {
        return NativeCollectionViewCell.self
    }
    
    var cellSize: CGSize {
        return _cellSize
    }
}
